//index.js

Page({
  data:{
    //轮播图数据
    swiperList:[],
    images:{}
  },
  onLoad:function(){
    this.setData({
      swiperList:[{"id":1,"imgurl":"/img/lb1.jpg"},{"id":2,"imgurl":"/img/lb2.jpg"},{"id":3,"imgurl":"/img/lb3.jpg"}]
    })
  },
  ziqu(){
    wx.switchTab({
      url: '/pages/spot/sindex'
    })
  },
  imageLoad: function(e) {
    var $width=e.detail.width,    //获取图片真实宽度
        $height=e.detail.height,
        ratio=$width/$height;    //图片的真实宽高比例
    var viewWidth=750,           //设置图片显示宽度，左右留有16rpx边距
        viewHeight=750/ratio+100;    //计算的高度值
     var image=this.data.images; 
     //将图片的datadata-index作为image对象的key,然后存储图片的宽高值
     image[e.target.dataset.index]={
        width:viewWidth,
        height:viewHeight
     }
     this.setData({
          images:image
     })
 }
})
